{{addToMap . "ContentTitle" "项目列表"}}
{{if eq .SubMenu "project_my"}}
{{addToMap . "ContentTitle" "我的项目"}}
{{end}}

<div class="content">
<div class="box">
  <div class="box-body">
    <table class="table table-bordered .table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>项目</th>
                <th>监控点</th>
                <th>相关人</th>
                <th>开启监控点</th>
                <th>最近24小时报警数</th>
                <th>负责人</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{ range .ProjectIds }}
            {{ $project := index $.Projects .}}
                <tr>
                    <td>{{$project.Id}}</td>
                    <td><a href="/project/{{$project.Id}}?listsubmenu={{$.SubMenu}}">{{$project.Title}}</a></td>
                    <td>{{ with index $.TracingNums $project.Id}} {{.Total}} {{else}} 0 {{ end }}</td>
                    <td>{{ with index $.UserNums $project.Id}} {{.Total}} {{else}} 0 {{ end }}</td>
                    <td>{{ with index $.TracingEnabledNums $project.Id}} {{.Total}} {{else}} 0 {{ end }}</td>
                    <td>{{ with index $.WarningNums $project.Id}} {{.Total}} {{else}} 0 {{ end }}</td>
                    <td>
                    {{ with index $.Users $project.UserId }}<a tabindex="0" class="user-popover" data-toggle="popover" data-trigger="focus" role="button" data-placement="bottom" data-content="<b>用户名:</b><br />{{.Username}}<br /><b>联系电话:</b><br/>{{.Phone}}<br /><b>邮箱:</b><br /> {{.Email}}">{{.Name}}</a>{{end}}
                    </td>
                    
                    <td>
                        {{if eq $project.UserId $.Uid}}
                        <a href="/project/{{$project.Id}}/update" class="icon-trash-empty j_edit">编辑</a> | <a href="#" class="icon-trash-empty j_del">删除</a>
                        {{else}}
                        无
                        {{end}}
                        
                    </td>
                </tr>
            {{ end }}
        </tbody>
    </table>
  </div>
    {{if .paginator}}
    <div class="box-footer clearfix">
    <nav class="text-center">
    <ul class="pagination pagination-sm">
        {{if .paginator.HasPrev}}
        <li>
            <a href="{{.paginator.PageLinkFirst}}">首页</a>
        </li>
        <li>
            <a href="{{.paginator.PageLinkPrev}}">上一页</a>
        </li>
        {{else}}
        <li class="disabled">
            <a>首页</a>
        </li>
        <li class="disabled">
            <a>上一页</a>
        </li>
        {{end}}

        {{range $index, $page := .paginator.Pages}}
        <li{{if $.paginator.IsActive .}} class="active"{{end}}>
            <a href="{{$.paginator.PageLink $page}}">{{$page}}</a>
        </li>
        {{end}}
        {{if .paginator.HasNext}}
        <li>
            <a href="{{.paginator.PageLinkNext}}">下一页</a>
        </li>
        <li>
            <a href="{{.paginator.PageLinkLast}}">末页</a>
        </li>
        {{else}}
        <li class="disabled">
            <a>下一页</a>
        </li>
        <li class="disabled">
            <a>末页</a>
        </li>
        {{end}}
    </ul>
    </nav>
    </div>
    {{end}}
</div>
</div>
<script type="text/javascript">
$(function(){
    $(function () {
        $('.user-popover').popover({html:true});
    })
});
</script>